﻿using System.Collections.Generic;
using System.Windows;
using System.Windows.Controls;

namespace WDCF
{
    /// <summary>
    /// ListView row formatter
    /// </summary>
    public class ListViewConditionalRowFormatter : ListViewConditionalFormatter
    {
        /// <summary>
        /// Creates a new instance of the <see cref="ListViewConditionalRowFormatter"/> class.
        /// </summary>
        /// <param name="listView"></param>
        /// <param name="conditions"></param>
        public ListViewConditionalRowFormatter(ListView listView, IList<Condition> conditions) 
            : base(listView, conditions)
        {
        }

        #region Overrides of ConditionalFormatter<ListView>

        /// <summary>
        /// Generates a <see cref="Style"/> object and applies it to the element.
        /// </summary>
        public override void Apply()
        {
            var style = GetStyle<ListViewItem>();

            if (style != null)
            {
                ListView.ItemContainerStyle = style;
            }
        }

        /// <summary>
        /// Gets the <see cref="Style"/> object which shall be replaced with
        /// conditional formatting.
        /// </summary>
        protected override Style TargetStyle
        {
            get { return null; }
        }

        #endregion
    }
}
